package edu.zut.cs.software.perfect.teacher.service.impl;

import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.base.service.impl.GenericManagerImpl;
import edu.zut.cs.software.perfect.teacher.dao.TeacherDao;
import edu.zut.cs.software.perfect.teacher.domain.Teacher;
import edu.zut.cs.software.perfect.teacher.service.TeacherManager;

/**
 * @ClassName TeacherManagerImpl
 * @Description TODO
 * @Author lixianglong
 * @Date 2020年6月2日 am11:26:49
 * @Version 1.0
 */
@Service("teacherManager")
public class TeacherManagerImpl extends GenericManagerImpl<Long, Teacher> implements TeacherManager {
	TeacherDao teacherdao;
	
	
	
	
	@Autowired
	public void setTeacherdao(TeacherDao teacherdao) {
		this.teacherdao = teacherdao;
		this.dao=this.teacherdao;
	}




	@Override
	public Teacher echo(Teacher teacher) {
		String content="liuxiaoming";
				teacher.setName(content);
				return teacher;
	}




	@Override
	public List<Teacher> findAll() {
		
		return (List<Teacher>) this.dao.findAll();
	}



	@Override
	public Optional<Teacher> findByWorkId(Long workid) {
		Optional<Teacher> result=this.dao.findById(workid);
		return result;
		
	}
	@Override
	public Boolean deleteById(Long courseId) {
		Optional<Teacher> teacher=this.dao.findById(courseId);
		if(teacher.equals(Optional.empty())) {
			return false;
		}else {
			this.dao.delete(teacher.get());
			return true;
		}
		
		
		
	}




	




	@Override
	public Teacher addTeacher(Teacher teacher) {
		
		return teacherdao.save(teacher);
	}


	
	
	
	/*@Override
	public Teacher echo(Teacher teacher) {
		String name="ming";
		String teachclass="ruanjian182";
		String course="software";
		teacher.setName(name);
		teacher.setWorkid((long)20170251);
		teacher.setCourse(course);
		teacher.setTeachclass(teachclass);
		return teacher;
	}*/
}
